package com.whale.kernel.service.hibernate;

import java.io.Serializable;

import com.whale.kernel.domain.HtmlMenu;
import com.whale.kernel.provider.ApplicationContextProvider;
import com.whale.kernel.service.TestService;

public class HibernateTestService extends AbstractHibernateService implements TestService {

	private ApplicationContextProvider applicationContextProvider;

	public void setApplicationContextProvider(
			ApplicationContextProvider applicationContextProvider) {
		this.applicationContextProvider = applicationContextProvider;
	}

	public Object findObject(Long id) {
		return hibernateTemplate.load(Object.class, id);
	}

	public Object updateObject(Long id) {
		TestService self = (TestService)applicationContextProvider.getApplicationContext().getBean("testService");
		self.findObject(id); // call function this service through proxy
		return null;
	}

	public void mytest() {
		HtmlMenu htmlMenu = new HtmlMenu();
		htmlMenu.setPath("mypath");
		htmlMenu.setNameCode("mycode");
		htmlMenu.setMenuGroupId("mygroup");
		htmlMenu.setMenuOrder(1);
		Serializable s = hibernateTemplate.save(htmlMenu);
		if (s!=null) {
			throw new RuntimeException("Test");
		}
	}
}
